#ifndef UNIVERSALQUERYMODEL_H
#define UNIVERSALQUERYMODEL_H

#include <QSqlQueryModel>
#include <QItemSelectionModel>

class UniversalQueryModel : public QSqlQueryModel
{
    Q_OBJECT

public:
    UniversalQueryModel(QObject *parent = 0);
    QString filter() ;
    void setSelectionModel(QItemSelectionModel *selModel);
    void selectRow(int rowId);
    virtual void sort(int column, Qt::SortOrder order);
    virtual void setFilter(const QString &filter);
    virtual void refresh();
    virtual void setSort(int column, Qt::SortOrder order);

private:
    QItemSelectionModel *selectionModel;
    QList<int> selRowIds;
    int currentSelId;
protected:
    int sortColumn;
    Qt::SortOrder sortOrder;
    QString sfilter;
    void saveSelState();
    void returnSelState();

signals:
    void dataChanged();


};

#endif // UNIVERSALQUERYMODEL_H
